﻿@using ComesEnCasa.Negocio
@model ComesEnCasa.Entidades.Entidad
@{
    var pepe = SexoNegocio.Listado();
    ViewBag.Title = ViewBag.Operacion;
    
}
<link href="~/Scripts/FileUploader/fileuploader.css" rel="stylesheet" />
<script src="~/Scripts/FileUploader/fileuploader.js"></script>
<script>
    $(function () {
        var uploader = new qq.FileUploader({
            element: document.getElementById('file-uploader-entidad'),
            action: '/Entidad/UploadImagen?entidadId=@Model.EntidadId',
            uploadButtonText: 'Examinar',
            onSubmit: function (file, extension) {
                $(".error-extensionInvalida-logotipo").css("display", "none");
                return true;

            },
            onComplete: function (file, response) {
                var random = Math.random(10000);
                $(".entidad-img").attr("src", "/Entidad/Imagen?entidadId=@Model.EntidadId&random=" + random);
            }
        });
    })
    
</script>

<style>
	input, select {
		display: block;
	}
    select {
	    background: none repeat scroll 0 0 #FFFFFF;
        border: 1px solid #E2E2E2;
        color: #333333;
        font-size: 1.2em;
        margin: 5px 0 6px;
        padding: 5px;
        width: 300px;
    }
</style>
<h2>@ViewBag.Operacion entidad</h2>

@using (Html.BeginForm((string)ViewBag.Operacion)) { @Html.ValidationSummary(true)

    <fieldset>
        @Html.HiddenFor(model => model.EntidadId)

        <legend>Entidad</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Cuil)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Cuil)
            @Html.ValidationMessageFor(model => model.Cuil)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Apellido)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Apellido)
            @Html.ValidationMessageFor(model => model.Apellido)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Nombre)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Nombre)
            @Html.ValidationMessageFor(model => model.Nombre)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.EstadoCivil)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.EstadoCivil)
            @Html.ValidationMessageFor(model => model.EstadoCivil)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.SexoId)
        </div>
        <div class="editor-field">
            @Html.DropDownList("SexoId", new SelectList(pepe, "SexoId", "Descripcion"), "-- Seleccione sexo --")
            @Html.ValidationMessageFor(model => model.SexoId)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.FechaNacimiento)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FechaNacimiento)
            @Html.ValidationMessageFor(model => model.FechaNacimiento)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.TipoDocumento)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.TipoDocumento)
            @Html.ValidationMessageFor(model => model.TipoDocumento)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.NroDocumento)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.NroDocumento)
            @Html.ValidationMessageFor(model => model.NroDocumento)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Observacion)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Observacion)
            @Html.ValidationMessageFor(model => model.Observacion)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Iva)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Iva)
            @Html.ValidationMessageFor(model => model.Iva)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Baja)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Baja)
            @Html.ValidationMessageFor(model => model.Baja)
        </div>
        
        @if (ViewBag.Operacion == "Editar")
        {
            <div class="editor-label">
                @Html.Label("Foto")
            </div>
            <div class="editor-field">
                <div class="clear" style="margin: 6px auto;">
                    <div class="img-preview left">
                        <img class="entidad-img" src="/Entidad/Imagen?entidadId=@Model.EntidadId" width="50" height="50"/>    
                    </div>
                    <div id="file-uploader-entidad" class="left">     
                        <noscript>          
                            <p>Please enable JavaScript to use file uploader.</p>
                        </noscript>         
                    </div>    
                </div>
            </div>
        }
        
       <p>
            <input type="submit" value="@ViewBag.Operacion" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Volver al listado", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
